<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no,adress=no"/>
<title>先花花</title>
<link rel="stylesheet" type="text/css" href="css/setting.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/sweet-alert.css" />
		 <!--<link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css"/>-->
         <link rel="stylesheet" href="css/style2.css"/>
<script type="text/javascript" src="script/jquery.js"></script>
<!--<script src="script/setting.js"></script>-->
</head>
<body onload="load()">
<!-- 页面头部 -->
<section>
 <div class="navigation-bar"> <a href="javascript:history.back(-1)" class="z-01"></a> <span>支付</span> <a href="index.html" class="z-02"></a> </div>
</section>
<!-- 中间内容 -->
<div class="m-wrapper">
  <div class="wrapper   ">
    <div class="login-password">
      <div class="container-fluid">
        
          <div class="form-group item">
					<div class="form-group item">
           <div class="main">
  <!--具体信息-->
  <div class="c-detailinfo">
    <dl>
      <dt>产品名称: <span id="proName"></span></dt>
    </dl>
    
    <dl>
      <dt>总金额: <font class="ui-fc-blue" id="loadMoney">0.00</font>元</dt>
    </dl>
    
    <dl>
      <dt>实付金额: <font class="ui-fc-blue" id="truePayMoney">0.00</font>元</dt>
    </dl>
    
    <dl>
      <dt>利率: <font class="ui-fc-blue" id="proProfit">0.00</font>%</dt>
    </dl>
    
    <dl>
      <dt>订单号: <font class="ui-fc-blue" id="orderSn"></font></dt>
    </dl>
    <div style="height: 20px;">
    	
    </div>
  </div>
</div>
			<div class="pwds-box">
				        <input type="tel" maxlength="6" class="pwd-input" id="pwd-input" data-role="none">
				        <div class="fake-box">
				            <input type="password" data-role="none" maxlength="1" readonly="">
				            <input type="password" data-role="none" maxlength="1" readonly="">
				            <input type="password" data-role="none" maxlength="1" readonly="">
				            <input type="password" data-role="none" maxlength="1" readonly="" >
				            <input type="password" data-role="none" maxlength="1" readonly="" >
				            <input type="password" data-role="none" maxlength="1" readonly="" >
				            <input type="password" data-role="none" maxlength="1" readonly="" >
				        </div>
				    </div>
          
          <div class="form-group">
            <button type="button" class="waves-button form-control login-button input-lg waves-effect waves-effect" tabindex="4" data-dismiss="modal" id="submits" style="background-color: #9D9D9D;" disabled=true>确定</button>
            <!-- Modal -->
          </div>
        <div>
          <p class="text-center ui-fs-12 text-nowrap pwdInput"></p>
          <p class="text-center ui-fs-12 text-nowrap"><span>021-110119120
          </span></p>
        </div>
        <div style="height: 40px;">
    	
    		</div>
      </div>
    </div>
  </div>
</div>
<input type="hidden" id='PayMoney'  >
<input type="hidden" id='orderNumber'  >
<!-- 页面底部 -->
<nav class="footer border_t" id="footer"> <a href="index.html" class="" id="jx"><span></span>首页</a> <a href="list.html" id="lc" class="nav_on"><span></span>理财</a> <a href="borrow_money.html" id="jk" class=""><span></span>借款</a> <a href="user.html" id="cf" class=""><span></span>我的账户</a> </nav>

<!--成功-->

<!--支付失败-->


</body>
</html>
<script type="text/javascript" src="script/jquery.cookie.js"></script>
<script type="text/javascript" src="script/jquery.md5.js"></script>
<!-- <script src="script/jquery.mobile-1.4.5.min.js"></script> -->
<script>
	  storage=window.localStorage;
  uid = storage['userid'];
	function load(){
		var get = new UrlSearch();
		if(!get.goods){
			alert('请选择产品');
			window.location.href="./list.html";
		}
		if(!get.money){
			alert('请输入购买金额');
			window.location.href="./infor4.html?goods="+get.goods;
		}
		$.ajax({
		  type:"get",
	      url:"http://47.93.21.169/old/TP5/public/index.php/index/orders/index",
	      dataType:'JSONP',
	      data:{id:uid,productId:get.goods,money:get.money},
	      jsonp:'callback',
	      success:function(e){
	      	// PayMoney = $.md5(e.data.money);
	      	// // alert(111)
	      	// orderNumber = e.data.orderNumber;
	      	// alert(PayMoney)
	      	if(e.success=='0'){
	      		alert(e.msg);
	      		window.location.href="./infor4.html?goods="+get.goods;
	      	}else if(e.success=='2'){
	      		alert(msg);
	      		window.location.href="./infor4.html?goods="+get.goods;
	      	}else{
	      		$('#proName').html(e.data.productName);
	      		$('#loadMoney').html(e.data.money);
				$('#truePayMoney').html(e.data.money);
				$('#proProfit').html(e.data.interestRate*100);
				$('#orderSn').html(e.data.orderNumber);
				$('#PayMoney').val(e.data.money);
				$('#orderNumber').val(e.data.orderNumber)
	      	}
	      }
		})
	}
	function UrlSearch()
	{
	   var name,value;
	   var str=location.href; //取得整个地址栏
	   var num=str.indexOf("?")
	   str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]

	   var arr=str.split("&"); //各个参数放到数组里
	   for(var i=0;i < arr.length;i++){
	    num=arr[i].indexOf("=");
	    if(num>0){
	     name=arr[i].substring(0,num);
	     value=arr[i].substr(num+1);
	     this[name]=value;
	     }
	    }
	}
</script>

   		<script type="text/javascript">
   			$(window).load(function(){
					$(".loading").fadeOut();
				})
   		</script>
<script>
var $input = $(".fake-box input");
$(".fake-box input").css({border:"1px solid #9D9D9D"});
        $("#pwd-input").on("input", function() {
            pwd = $(this).val().trim();     
            for (var i = 0, len = pwd.length; i < len; i++) {
                $input.eq("" + i + "").val(pwd[i]);
            }
            $input.each(function() {
                var index = $(this).index();
                if (index >= len) {
                    $(this).val("");
                }
                if (len == '6') {
					$(".fake-box input").css({border:"1px solid #009dd9"});
                    $("#submits").css({backgroundColor:"#009dd9"})
                    $("#submits").attr('disabled',false);
                }else{
                	$(".fake-box input").css({border:"1px solid #9D9D9D"});
                	$("#submits").css({backgroundColor:"#9D9D9D"})
                	$("#submits").attr('disabled',true);
                }
            });
            
        });
        $(document).on("click","#submits",function(){
        // 	alert(1)
        // 	return false;
        	var orderSn = $("#orderSn").text();
        	// alert(pwd)
        	// alert(123)
        	//验证支付密码
  				var appid = $.md5("123");
				  var appkey = $.md5("1aaaa");
				  var money=parseInt($('#PayMoney').val());
				  pwds = $.md5(pwd);
				   // alert(pwds)
				   $.ajax({
				          url:"http://47.93.21.169/old/TP5/public/index.php/index/Userinfo/reduce",
				          data:{'appid':appid,'appkey':appkey,'uid':uid,'payPwd':pwds,'PayMoney':money},
				          type:"get",
				          dataType:"jsonp",
				          jsonp:"callback",
				          success:function(e){
				            if(e.status==200){
				            	getAjax(money);
				            }else{
				            	alert('支付密码错误，请重新输入')
				            }
				          }
				      });
  			})
        function getAjax(money){
        	var get = new UrlSearch();
        	var orderNumber=$('#orderNumber').val();
        	$.ajax({
        		  type:"get",
			      url:"http://47.93.21.169/old/TP5/public/index.php/index/orders/saveOrder",
			      dataType:'JSONP',
			      data:{orderNumber:orderNumber,pid:get.goods,surplusMoney:money,uid:uid},
			      jsonp:'callback',
			      success:function(e){
			      		alert('支付成功');
			      		window.location.href="deposits.html";
			      }
        	})
        }
        
</script>